package com.yhhvip.rest.controller;
import com.yhhvip.rest.service.GoodsService;
import com.yhhvip.utils.JsonResult;
import com.yhhvip.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    @RequestMapping("/goodsBrand")
    public JsonResult goodsBrand(){
        try{
            return goodsService.goodsBrand();
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.build(503,e.getMessage());
        }
    }
    @RequestMapping("/goodsTopicsActivityAll")
    public JsonResult goodsTopicsActivityAll(String page,String size){
        try{
            return goodsService.goodsTopicsActivityAll(page,size);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.build(503,e.getMessage());
        }
    }

    @RequestMapping("/goodsCommodity")
    public JsonResult goodsCommodity(Integer brandId){
        try{
            return goodsService.goodsCommodity(brandId);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.build(503,e.getMessage());
        }
    }

    @RequestMapping("/goodsCommodityByTAId")
    public JsonResult goodsCommodityByTAId(String topicsActivityId,String isStock,String isDiscount,String isPrice,String page,String size) {
        try{
            return goodsService.goodsCommodityByTAId(topicsActivityId,isStock,isDiscount,isPrice,page,size);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.build(503,e.getMessage());
        }
    }
    @RequestMapping("/goodsCommodityInfo")
    public JsonResult goodsCommodityInfo(Integer commodityId) {
        try{
            return goodsService.goodsCommodityInfo(commodityId);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.build(503,e.getMessage());
        }
    }
    @RequestMapping("/goodsIsAttention")
    public JsonResult goodsIsAttention(String commodityId,String USER_KEY) {
        try{
            return goodsService.goodsIsAttention(commodityId,USER_KEY);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.build(503,e.getMessage());
        }
    }
    @RequestMapping("/goodsAttention")
    public JsonResult goodsAttention(String USER_KEY) {
        try{
            return goodsService.goodsAttention(USER_KEY);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.build(503,e.getMessage());
        }
    }
    @RequestMapping("/goodsJoinattention")
    public JsonResult goodsJoinattention(String USER_KEY,Integer commodityId) {
        try{
            return goodsService.goodsJoinattention(USER_KEY,commodityId);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.build(503,e.getMessage());
        }
    }
    @RequestMapping("/goodsShopCartByUser")
    public JsonResult goodsShopCartByUser(String USER_KEY) {
        try{
            return goodsService.goodsShopCartByUser(USER_KEY);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.build(503,e.getMessage());
        }
    }
    @RequestMapping("/goodsJoinShop")
    public JsonResult goodsJoinShop(String USER_KEY,Integer amount,Integer cSId){
        try{
            return goodsService.goodsJoinShop(USER_KEY,amount,cSId);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.build(503,e.getMessage());
        }
    }
    @RequestMapping("/goodsJoinShop1")
    public JsonResult goodsJoinShop1(String USER_KEY,Integer amount,Integer cSId){
        try{
            return goodsService.goodsJoinShop1(USER_KEY,amount,cSId);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.build(503,e.getMessage());
        }
    }
    @RequestMapping("/goodsDelShop")
    public JsonResult goodsDelShop(String USER_KEY,Integer shopCartId){
        try{
            return goodsService.goodsDelShop(USER_KEY,shopCartId);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.build(503,e.getMessage());
        }
    }
    @RequestMapping("/goodsFindShopCSRelation")
    public JsonResult goodsFindShopCSRelation(String USER_KEY,String shopCartIdJson){
        try{
            return goodsService.goodsFindShopCSRelation(USER_KEY,shopCartIdJson);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.build(503,e.getMessage());
        }
    }
    @RequestMapping("/goodsFindCSRelation")
    public JsonResult goodsFindCSRelation(String USER_KEY,String CSId,String buyAmount){
        try{
            return goodsService.goodsFindCSRelation(USER_KEY,CSId,buyAmount);
        }catch (Exception e){
            e.printStackTrace();
            return JsonResult.build(503,e.getMessage());
        }

    }
}
